<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="vue.js"></script>
</head>

<body>
    <div id="root">
        <input type="text" v-model="msg">
        <h1>{{msg | replace}}</h1>

        <input type="text" v-model="number">
        <h1 v-if="number!=''">{{number | numReplace}}元</h1>

    </div>

    <script>
        Vue.config.productionTip = false;

        const vm = new Vue({
            el: '#root',
            data: {
                msg: '',
                number: '',
            },
            filters: {
                replace(value) {
                    return value.replace(/\s/g, "");
                },
                numReplace(value) {
                    return parseFloat(value).toFixed(2);
                },
            }
        })
    </script>
</body>

</html>